package com.xuecheng.media.controller;

import com.xuecheng.base.result.RestResponse;
import com.xuecheng.media.model.dto.AuditFailDTO;
import com.xuecheng.media.service.IMediaAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

/**
 * @author 勾新杰
 * @version 1.0
 * @description: 媒资审核控制层，本来的思路是定时任务去审核待审核的视频列表，但是阿里云视频审核需要钱，就降级处理吧。
 * @date 2025/2/16 20:26
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/audit")
@Api(tags = "媒资审核接口")
public class MediaAuditController {

    /**
     * 媒资审核服务
     */
    private final IMediaAuditService mediaAuditService;

    /**
     * 执行成功
     */
    private static final String EXECUTE_SUCCESS = "执行成功";

    /**
     * 审核成功
     *
     * @param mediaId 媒资id
     * @return {@link RestResponse}<{@link String}> 审核成功
     */
    @PutMapping("/success/{mediaId}")
    @ApiOperation("审核成功")
    public RestResponse<String> auditSuccess(@PathVariable String mediaId) {
        mediaAuditService.auditSuccess(mediaId);
        return RestResponse.success(EXECUTE_SUCCESS);
    }

    /**
     * 审核失败
     *
     * @param mediaId 媒资id
     * @return {@link RestResponse}<{@link String}> 审核失败
     */
    @PutMapping("/fail/{mediaId}")
    @ApiOperation("审核失败")
    public RestResponse<String> auditFail(@PathVariable String mediaId,
                                          @RequestBody @Validated AuditFailDTO auditFailDTO) {
        mediaAuditService.auditFail(mediaId, auditFailDTO);
        return RestResponse.success(EXECUTE_SUCCESS);
    }
}
